package com.pi.pro.xcmg.am.was.fac.service;


import com.pi.common.utils.StringUtils;
import com.pi.core.exchange.vo.CommonNameRegistryService;
import com.pi.pro.xcmg.am.common.XcmgAmConstants;
import com.pi.pro.xcmg.am.common.vo.edi.KitDocumentQueryData;
import com.pi.pro.xcmg.am.common.vo.edi.KitDocumentReplyData;
import com.pi.pro.xcmg.am.was.edi.mes.common.MesWasExchangeSupport;
import com.pi.pro.xcmg.am.was.edi.mes.service.KitDocumentServiceProxy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 *
 */
@Slf4j
@Service
public class MesCustomWorkService {

    @Autowired
    private CommonNameRegistryService mesNameRegistryService;


    //-----------------------------------------------------------------------
    // 获取配盘单
    //-----------------------------------------------------------------------
    /**
     *  查询
     * */
    //
    public KitDocumentReplyData query(Long divisionId, String documentNumber){
        KitDocumentReplyData resultData = MesWasExchangeSupport.ok();
        if (StringUtils.isNullOrBlank(documentNumber)){
            return resultData;
        }
        String m="";
        //
        if (divisionId==null){
            divisionId=XcmgAmConstants.DIVISION_WH101_ID;
        }
        KitDocumentServiceProxy proxy = null;
        KitDocumentQueryData params=null;
        try{
            //
            proxy = this.mesNameRegistryService.takeProxy(XcmgAmConstants.CLIENT_ID_XCMG, divisionId, KitDocumentServiceProxy.class);
            if (proxy == null) {
                m = "not found task proxy";
                resultData = MesWasExchangeSupport.error(m);
                return resultData;
            }
            params=new KitDocumentQueryData();
            params.setPollNo(documentNumber.trim());
            resultData=proxy.query(params);
        }catch (Exception e){
            e.printStackTrace();
        }
        return resultData;
    }

}
